#include <iostream>
using namespace std;



    inline int getNBits(unsigned int num){
        int res = 0;
        while(num!=0){
            num >>= 1;
            ++res;
        }
        return res;

    }

    int divide(int dividend, int divisor) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        unsigned int absDividend = dividend > 0? dividend : - dividend;
        unsigned int absDivisor = divisor > 0? divisor : -divisor;

        int res = 0;
        if(absDivisor > absDividend){
            return 0;
        }    

        int bitsDend = getNBits(absDividend);
        int bitsSor = getNBits(absDivisor);
        int deltaBits = bitsDend - bitsSor;
        unsigned int tmpSor = absDivisor << deltaBits;

        for(int i=0; i<=deltaBits; ++i){
            res <<= 1;
            if(absDividend >= tmpSor){
                absDividend -= tmpSor;
                res += 1;
            }
            tmpSor >>= 1;
        }

        if((dividend>0 && divisor>0) || (dividend<0 && divisor<0)){
            return res;
        }
        else{
            return -res;
        }
    }


int main(){

    cout<<divide(-2147483648, -3)<<endl;

    return 0;
}